package top.toptimus.dto.project.projectItem;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * WBS模板
 *
 * @author gaoyu
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class WBSTemplateDTO {
    private String id;
    private String templateName;    //  WBS模板名称
    private List<WBSItemDTO> wbsItemDTOList = new ArrayList<>();

    /**
     * 排序
     *
     * @return this
     */
    public WBSTemplateDTO buildSort() {
        this.wbsItemDTOList.sort(WBSItemDTO::compareTo);
        for (int i = 0; i < this.wbsItemDTOList.size(); i++) {
            wbsItemDTOList.get(i).setIndex(i);
        }
        return this;
    }
}
